<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

$id = UV::readInt(strip_tags($route->getByNum(5)));

if (UV::readMQ(strip_tags($route->POST("act"))) == "post")
{
	$text = UV::readMQ(strip_tags($route->POST("text")));
	$db->sendQuery("update `news_comments` set `text` = '$text' where `nc_id` = '$id' limit 1");
}

$comment = $db->getRow("select `C`.*,`N`.`title`,`U`.`login`
from `news_comments` as `C`
left join `news` as `N` on
`C`.`news_id` = `N`.`news_id`
left join `users` as `U` on
`C`.`user_id` = `U`.`user_id`
where `nc_id` = '$id' limit 1");

require_once ADMIN.DS."head.php";
?>

<div class="full">
	<div class="submenu_container">
		<a class="submenu_button" href='/admin/moder/comments/view'>Комментарии</a>
		<a class="submenu_button" href='/admin/moder/news/view'>Новости</a>
		<a class="submenu_button submenu_button_active">Редактирование комментария</a>
	</div>
	<h3>Редактирование комментария</h3>
	<form method='post'>
		<input type='hidden' name='act' value='post' />
		<table cellspacing='10'>
			<tr>
				<td width="150px">ID</td>
				<td><a href='/news/<?php echo $comment['news_id']."#comment_".$comment['nc_id']; ?>'><?php echo "#".$comment['nc_id']; ?></a></td>
			</tr>
			<tr>
				<td>Пользователь</td>
				<td><a href='/user/<?php echo $comment['login']; ?>'><?php echo $comment['login']; ?></a> <?php echo "[".$comment['user_ip']."]"; ?></td>
			</tr>
			<tr>
				<td>К статье</td>
				<td><a href='/news/<?php echo $comment['news_id']; ?>'><?php echo $comment['title']; ?></a></td>
			</tr>
			<tr>
				<td>Время</td>
				<td><?php echo date("H:i d.m.Y",$comment['time']); ?></td>
			</tr>
			<tr>
				<td><label for='text'>Текст</label></td>
				<td><textarea name='text' id='text' cols='50' rows='5'><?php echo $comment['text']; ?></textarea></td>
			</tr>
			<tr>
				<td align='right' colspan='2'><input type='submit' value='Редактировать' style="padding: 5px 20px" /></td>
			</tr>
		</table>
	</form>
</div>

<?php require_once ADMIN.DS."footer.php"; ?>